package cn.saas.room;

import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.shehuan.niv.NiceImageView;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //I miss that miss when I miss her
        ImageView imageView = (ImageView) findViewById(R.id.iv);
        NiceImageView niceImageView = (NiceImageView) findViewById(R.id.niv);

        new Thread(() -> {
            StudentDatabase database = Room.databaseBuilder(this, StudentDatabase.class, "aaa.db").build();
            database.getStudentDao().insertStudent(getStudentBean());
        }).start();

        String packageName = this.getPackageName()+ File.separator;
        Log.e("aaaaa", "onCreate: "+packageName );

        RequestOptions requestOptions = new RequestOptions();
        requestOptions.placeholder(R.drawable.ic_launcher_background);
        requestOptions.circleCropTransform();
        requestOptions.transforms( new RoundedCorners(60));
        Glide.with(this).load(R.drawable.ic_launcher_background) //图片地址
                .apply(requestOptions)
                .into(imageView);
        niceImageView.setImageResource(R.drawable.ic_launcher_background);
    }

    private StudentDb getStudentBean() {
        StudentDb studentDb = new StudentDb();
        studentDb.setAge(11);
        studentDb.setName("lsngo");
        return studentDb;
    }
}